<?php

// 然后创建数据表
header("Conter-type:text/html;charset=uft8");

$servername = "localhost";
$username = "root";
$password = "root";
$dbname="bbv";

try{
    $conn = new PDO("mysql:host=$servername;dbname=$dbname",$username,$password);
   
    // 设置抛出错误
    $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);

    //在数据表中添加数据
    $sql = "create table bbv (
        id int(6) unsigned auto_increment primary key,
        firstname varchar(30) not null,
        lastname varchar(30) not null,
        email varchar(50),
        reg_date timestamp
    )";

    // 使用执行程序，因为没有返回结果
    $conn->exec($sql);
    echo "这个数据已经成功添加了";
}
catch(PDOExeption $e){
    echo $sql . "<br/>" . $e->getMessqge();
}